<!DOCTYPE html>  
<html>  
    <button onclick="notifyMe()">Notify me!</button>
    <script type="text/javascript">
        function notifyMe() {
            // 先检查浏览器是否支持
            if (!("Notification" in window)) {
                alert("This browser does not support desktop notification");
            }

            // 检查用户是否同意接受通知
            else if (Notification.permission === "granted") {
                // If it's okay let's create a notification
                var options = {
                    body: 'body ......',
                    icon: 'file:///home/jie/图片/kylin-video.svg'
                }
                var notification = new Notification("Hi there!",options);
                setTimeout(notification.close.bind(notification), 4000);
            }

            // 否则我们需要向用户获取权限
            else if (Notification.permission !== "denied") {
                Notification.requestPermission().then(function (permission) {
                // 如果用户接受权限，我们就可以发起一条消息
                if (permission === "granted") {
                    var notification = new Notification("Hi there!");
                }
                });
            }
        }

    </script>

</html>  
